<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>购物车 - 宠物商城</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="/">宠物商城</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-label="切换导航">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#" id="categoriesLink">商品分类</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link active" href="/cart.html">购物车</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/orders.html">我的订单</a>
                    </li>
                </ul>
                <div id="userActions">
                    <!-- 用户操作区域将通过JavaScript动态加载 -->
                </div>
            </div>
        </div>
    </nav>

    <!-- 购物车内容 -->
    <div class="container mt-4">
        <h2 class="mb-4">我的购物车</h2>
        <div class="table-responsive">
            <table class="table">
                <thead>
                    <tr>
                        <th>商品图片</th>
                        <th>商品名称</th>
                        <th>单价</th>
                        <th>数量</th>
                        <th>小计</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody id="cartList">
                    <!-- 购物车列表将通过JavaScript动态加载 -->
                </tbody>
            </table>
        </div>

        <!-- 购物车为空时的提示 -->
        <div id="emptyCart" class="text-center py-5 empty-cart">
            <h3>购物车是空的</h3>
            <p>快去挑选一些商品吧！</p>
            <a href="/" class="btn btn-primary">去购物</a>
        </div>

        <!-- 结算区域 -->
        <div class="row justify-content-end mt-4">
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">订单总计</h5>
                        <div class="d-flex justify-content-between mb-2">
                            <span>商品总价：</span>
                            <span id="totalPrice">¥0.00</span>
                        </div>
                        <button class="btn btn-primary w-100" onclick="checkout()">结算</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 页脚 -->
    <footer class="bg-dark text-white mt-5 py-3">
        <div class="container text-center">
            <p>&copy; 2024 宠物商城. All rights reserved.</p>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="js/cart.js"></script>
</body>
</html> 